<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>教学实验环境管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
			$("#pageNo").val(n);
			$("#pageSize").val(s);
			$("#searchForm").submit();
        	return false;
        }
		function configCtfSetBox(){
			top.$.jBox("<div class='form-search' style='padding-left:20px; padding-top: 20px; padding-bottom: 15px;'>是否可以查看解题思路</div>"+
					"<div class='form-search' style='padding-left:30px; padding-bottom: 20px;'><input type='radio' id='solutionYes' name='solutionIsAllow' value='0'/>是<br/>"+
					"<input type='radio' id='solutionNo' name='solutionIsAllow' value='1' checked='checked'/>否</div>",
					{
						title: "配置CTF题目集",
						submit: function (v, h, f) {
							alertx("hahaha"+ f.solutionIsAllow);

						}
					});
			return false;
		}
		function createInstance(id)
		{
//			$("#maskDIV").show();
//
//			var hidd=window.parent.document.getElementById("hffegeg");
//			alert(hidd);
//			showmask();
			var s = window.parent.document.getElementById("maskDIV");
			s.style.display = "block";
			$.ajax({
				type: "POST",
				url: "${ctx}/scene/sceneEnvironment/createInstance",
				data: {
					ids:id
				},
				success: function (instanceId) {
//					$("#maskDIV").hide();
//					closemask();

					//关闭遮罩
					var s = window.parent.document.getElementById("maskDIV");
					s.style.display = "none";
					window.location.href="${ctx}/scene/sceneEnvironmentInstance/list";

					<%--window.open("${ctx}/scene/sceneEnvironmentInstance/list","_blank");--%>


				},
				error:function(){
					//关闭遮罩
					var s = window.parent.document.getElementById("maskDIV");
					s.style.display = "none";
					alert("生成实例失败");
				}
			});

		}

		function test(id)
		{
//			$("#maskDIV").show();
//
//			var hidd=window.parent.document.getElementById("hffegeg");
//			alert(hidd);
//			showmask();
			var s = window.parent.document.getElementById("maskDIV");
			s.style.display = "block";
			$.ajax({
				type: "POST",
				url: "${ctx}/scene/sceneEnvironment/test",
				data: {
					ids:id
				},
				success: function (instanceId) {
//					$("#maskDIV").hide();
//					closemask();

					//关闭遮罩
					var s = window.parent.document.getElementById("maskDIV");
					s.style.display = "none";
//					document.getElementById("testA").setAttribute('href',"https://www.baidu.com/");
//					document.getElementById("testA").href="https://www.baidu.com/";
					window.location.href="${ctx}/scene/sceneEnvironmentInstance/";
					<%--window.open("${ctx}/scene/sceneEnvironmentInstance/","_blank");--%>


				},
				error:function(){
					var s = window.parent.document.getElementById("maskDIV");
					s.style.display = "none";
					alert("生成实例失败");
				}
			});

		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/scene/sceneEnvironment/">教学实验环境列表</a></li>
		<shiro:hasPermission name="scene:sceneEnvironment:edit"><li><a href="${ctx}/scene/sceneEnvironment/form">教学实验环境添加</a></li></shiro:hasPermission>
	</ul>
	<jsp:useBean id="sceneEnvironment"  class="com.lczyfz.istep.modules.scene.entity.SceneEnvironment" scope="request" ></jsp:useBean>
	<form:form id="searchForm" modelAttribute="sceneEnvironment" action="${ctx}/scene/sceneEnvironment/" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>名称：</label>
				<form:input path="environmentName" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<li><label>类型：</label>
				<form:select path="environmentType" class="input-medium">
					<form:option value="" label=""/>
					<c:choose>
						<c:when test="${isSuperAdmin=='false'}">
							<form:option value="0">${fns:getDictLabel("0",'scene_env_type',"无")}</form:option>
						</c:when>
						<c:otherwise>
							<form:options items="${fns:getDictList('scene_env_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>

						</c:otherwise>
					</c:choose>
				</form:select>
			</li>
			<%--<li><label>实验时间：</label>--%>
				<%--<form:select path="environmentTime" class="input-medium">--%>
					<%--<form:option value="" label=""/>--%>
					<%--<form:options items="${fns:getDictList('scene_env_time')}" itemLabel="label" itemValue="value" htmlEscape="false"/>--%>
				<%--</form:select>--%>
			<%--</li>--%>
			<li><label>标签：</label>
				<form:input path="label" htmlEscape="false" maxlength="64" class="input-medium"/>
			</li>
			<%--<li><label>创建时间：</label>--%>
				<%--<input name="beginCreateDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"--%>
					<%--value="<fmt:formatDate value="${sceneEnvironment.beginCreateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"--%>
					<%--onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/> - --%>
				<%--<input name="endCreateDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"--%>
					<%--value="<fmt:formatDate value="${sceneEnvironment.endCreateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"--%>
					<%--onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>--%>
			<%--</li>--%>
			<%--<li><label>更新时间：</label>--%>
				<%--<input name="beginUpdateDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"--%>
					<%--value="<fmt:formatDate value="${sceneEnvironment.beginUpdateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"--%>
					<%--onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/> - --%>
				<%--<input name="endUpdateDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"--%>
					<%--value="<fmt:formatDate value="${sceneEnvironment.endUpdateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"--%>
					<%--onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>--%>
			<%--</li>--%>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<%--<a onclick="test('${sceneEnvironment.id}')" target="_blank" id="testA">测试</a>--%>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th>教学实验环境名称</th>
				<th>教学实验环境类型</th>
				<th>实验时间</th>
				<th>实验设备访问方式</th>
				<th>标签</th>
				<shiro:hasPermission name="scene:sceneEnvironment:edit"><th>操作</th></shiro:hasPermission>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="sceneEnvironment">
			<tr>
				<td><a href="${ctx}/scene/sceneEnvironment/form?id=${sceneEnvironment.id}">
					${sceneEnvironment.environmentName}
				</a></td>
				<td>
					${fns:getDictLabel(sceneEnvironment.environmentType, 'scene_env_type', '')}
				</td>
				<td>
					${fns:getDictLabel(sceneEnvironment.environmentTime, 'scene_env_time', '')}
				</td>
				<td>
					${fns:getDictLabel(sceneEnvironment.environmentAccessMode, 'scene_env_access_mode', '')}
				</td>
				<td>
					${sceneEnvironment.label}
				</td>
				<shiro:hasPermission name="scene:sceneEnvironment:edit"><td>
					<a href="${ctx}/scene/sceneEnvironment/detail?id=${sceneEnvironment.id}">详情</a>
					<c:choose>
						<c:when test="${sceneEnvironment.environmentType=='1'&&isSuperAdmin=='false'}">
							<a style="text-decoration: none; color: grey; pointer-events: none;">修改</a>
							<a style="text-decoration: none; color: grey; pointer-events: none;">删除</a>

						</c:when>
						<c:otherwise>
							<a href="${ctx}/scene/sceneEnvironment/form?id=${sceneEnvironment.id}">修改</a>
							<a href="${ctx}/scene/sceneEnvironment/delete?id=${sceneEnvironment.id}" onclick="return confirmx('确认要删除该教学实验环境吗？', this.href)">删除</a>
						</c:otherwise>
					</c:choose>
					<%--<a href="${ctx}/scene/sceneEnvironment/createInstance?id=${sceneEnvironment.id}">生成实例</a>--%>
					<a onclick="createInstance('${sceneEnvironment.id}')" target="_blank" href="javascript:void(0)">生成实例</a>



				<%--<a href="${ctx}/scene/sceneEnvironment/experimentOperate?environmentId=6c12dcd7-33e4-11e7-a0f2-d8cb8a6cc1b8&courseId=ddeb1197-1364-11e7-84e8-d8cb8a6cc1b8&coursewareId=75a639da6ec54929a63dd82459a0d07c" target="_blank">进入实验</a>--%>

				</td></shiro:hasPermission>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	<script type="text/javascript">

//		$(function(){
//			$("<div id='maskDIV'><i class='icon-spinner icon-spin white' style='font-size:550%;position: relative;top: 47%;left: 48%;'></i>" +
//					"<span style='position: relative;color: white;top: 50%;left:39%;font-size:20px;'>文件上传中，请稍候...</span></div>").css({
//				position: 'absolute',
//				bottom: 0,
//				left: 0,
//				backgroundColor: "#393939",
//				opacity: 0.5,
//				zIndex: 1040
//			}).height($(document).height()).width($(document).width()).hide().appendTo("body");
//
//		});
function showmask(){
	var s = window.parent.document.getElementById("maskDIV");
	s.style.display = "block";
}

function closemask(){
	var s = window.parent.document.getElementById("maskDIV");
	s.style.display = "none";
}
	</script>
</body>

</html>